package edu.uta.cfl.engine;

import edu.uta.cfl.data.Combo;
import edu.uta.cfl.data.Component;
import edu.uta.cfl.data.IterationResult;
import edu.uta.cfl.data.Parameter;
import edu.uta.cfl.data.SUT;
import edu.uta.cfl.util.Util;

public class IterationOutput {

	public IterationOutput()
	{

	}

	public void printSuspiciousCombinations(SUT sut,IterationResult itr,int len)
	{
		for (Combo cmb : itr.getSuspiciousCombos()) {

			System.out.println(ComboManager.ToString(cmb, sut.getParameters()));
			System.out.printf(" , %f , %f \n", cmb.getRankValue(),
					cmb.getEnvRankValue());
		}
	}

	public void printSuspiciousComponent(SUT sut, IterationResult itr,int len)
	{
		for(Component cmp : itr.getSuspiciousComponents())
		{

			int i = sut.getParameters().indexOf(cmp.getParameter());
			System.out.print(cmp.getParameter().getName()
					+ "="
					+ sut.getParameters().get(i).getValues()
							.get(cmp.getValue()));
			System.out.printf(" , %f , %f , %f , %f\n", cmp.getPart1(),
					cmp.getPart2(), cmp.getPart3(), cmp.getRankValue());

		}
	}

	public void printRecommendedTestSet(SUT sut, IterationResult itr)
	{

		System.out.println("# Executing these new test cases recommended by algorithm.");
		System.out.println("Tests");

		String output = "Test #, ";
		for (Parameter prm : sut.getParameters())
			output += prm.getName() + ", ";

		try {
			System.out.println(output.substring(0, output.lastIndexOf(",")));
			int stater = 0;
			int i;
			String test;
			for (int[] tc : itr.getTestSet()) {

				test = "" + stater++ + " , ";
				for (i = 0; i < tc.length - 1; i++)
					test += sut.getParameters().get(i).getValues().get(tc[i]) + " , ";

				test += tc[tc.length - 1];
				System.out.println(test);
			}


		} catch (Exception e) {

		}




	}

}
